package com.ruoyi.camp.api;

import com.ruoyi.camp.domain.Project;
import com.ruoyi.camp.domain.ScenicSpots;
import com.ruoyi.camp.service.IProjectService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/wechat/project")
public class WxProjectController extends BaseController {

    @Autowired
    private IProjectService projectService;

    @GetMapping("/getInfoByCampId/{campId}")
    public AjaxResult getInfoByCampId(@PathVariable("campId") String campId) {
        if (campId == null) {
            return error("营地Id不能为空");
        }
        List<Project> list = projectService.getInfoByCampId(campId);
        return success(list);
    }

    @PostMapping("/add")
    public AjaxResult add(@RequestBody Project project){
        if (project == null) {
            return error("数据不能为空");
        }
        return toAjax(projectService.insertProject(project));
    }

    @DeleteMapping("/{projectIds}")
    public AjaxResult remove(@PathVariable String[] projectIds){
        return toAjax(projectService.deleteProjectByProjectIds(projectIds));
    }
}
